import request from "@/utils/request";
import {
  ResCategoryList,
  ResBigCategoryList,
  ResCategoryAddParams,
  ResCategoryEditParams,
  ReqGetDifficulty,
  ReqGetCategoryId,
} from "./model";

// 获取分类列表
export const reqCategoryList = (data: PageQuery) => {
  return request<any, PageResult<ResCategoryList[]>>({
    url: "/admin/getcategory",
    params: data,
  });
};

// 获取大分类列表
export const reqBigCategoryList = () => {
  return request<any, ResBigCategoryList[]>({
    url: "/admin/getBigCategory",
  });
};

// 添加分类列表
export const reqCategoryAdd = (data: ResCategoryAddParams) => {
  return request({
    url: "/admin/categoryCreate",
    method: "post",
    data,
  });
};

// 编辑分类列表
export const reqCategoryEdit = (data: ResCategoryEditParams) => {
  return request({
    url: "/admin/categoryUpdate",
    method: "post",
    data,
  });
};

// 删除小分类
export const reqCategoryDel = (id: number) => {
  return request({
    url: "/admin/categoryDelete",
    params: { id },
  });
};

// 获取难度列表
export const reqGetDifficulty = () => {
  return request<any, ReqGetDifficulty[]>({
    url: "/admin/getdifficulty",
  });
};

// 获取分类id
export const reqGetCategoryId = (script_id?: number) => {
  return request<any, ReqGetCategoryId[]>({
    url: "/admin/getScriptCate",
    params: { script_id },
  });
};
